<template>
  <div>
     <div>
    <div class="background"></div>
    <div class="content"></div>
    <div class="background">
<img :src="imgSrc" width="95%" height="100%" alt="" style="margin-left: -300px" /></div>
  </div>
  <br><br><br><br><br><br>
    <div>
      <el-form :model="A" :rules="rules" ref="userForm">
        <el-form-item prop="password">
          <el-input
            placeholder="请再密码"
            size="medium"
            style="margin: 10px 0; width: 300px"
            prefix-icon="el-icon-lock"
            show-password
            v-model="A.password"
          ></el-input>
        </el-form-item>
        <el-form-item prop="confirmPassword">
          <el-input
            placeholder="请再输入一次密码"
            size="medium"
            style="margin: 10px 0; width: 300px"
            prefix-icon="el-icon-lock"
            show-password
            v-model="A.confirmPassword"
          ></el-input>
        </el-form-item>
        <el-button type="primary" @click="mimaUpd()">确定</el-button>
        <el-button type="primary" @click="quxiao()">取消</el-button>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    var checkPwd = (rule, value, callback) => {
      if (value.trim().length == 0) {
        callback(new Error("请确认密码不能为空"));
      } else if (value != this.A.password) {
        callback(new Error("两次密码不一致"));
      } else {
        callback();
      }
    };
    return {
    imgSrc:require('../tupian/poluo.jpg'),
      A: {
        id: 2,
        password: "",
        confirmPassword: "",
      },
      rules: {
        password: [
          {
            required: true,
            message: "请输入密码",
            trigger: "blur",
          },
          {
            min: 5,
            max: 10,
            message: "长度在 5 到 10 个字符",
            trigger: "blur",
          },
        ],
        confirmPassword: [
          {
            validator: checkPwd,
            trigger: "blur",
          },
        ],
      },
    };
  },
  methods: {
      mimaUpd() {
      this.$refs['userForm'].validate((valid) => {
        if (valid) {  // 表单校验合法
          this.$axios.get("/user/user/doctor/ren/mimaUpd/"+ this.A.id + "/" + this.A.password)
            .then(res =>{
                alert("修改成功！！！")
                //this.$message.success(res.message)
                this.$router.push("/login")
            }).catch(err =>{
                this.$router.push("/")
                this.$message.error(res.message)
            })

        }
      });
   },
    findAdminAll() {
      this.$axios.get("/user/user/doctor/ren/findAdminAll").then((res) => {
        this.Data = res.data.data.list;
      });
    },

    quxiao() {
      this.$router.push({ path: "/Administrator" });
    },
  },
};
</script>

<style>
.background {
    width:100%;
    height:100%;  /**宽高100%是为了图片铺满屏幕 **/
    z-index:-1;
    position: absolute;

}
 .content {
    z-index:1;
    position: absolute;
}
</style>
